﻿@using CoreData
@model IEnumerable<Product>
@if (Model != null && Model.Count() > 0)
{
    int i = 0;
    <table cellpadding="0" cellspacing="0" width="100%" class="table" id="tSortable">
        <thead>
            <tr>
                <th width="20px">
                    
                </th>
                <th>
                    Special code
                </th>
                <th>
                    Special name
                </th>
                <th width="70px">
                    Image
                </th>
                 <th>
                   Category
                </th>
                <th>
                    Old Price
                </th>
                <th>
                    New Price
                </th>
                <th>
                    Start date
                </th>
                <th>
                    End date
                </th>
                
                <th width="60px">
                    Active
                </th>
                <th width="60px">
                   Action
                </th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                i++;
                <tr>
                    <td>
                        @i
                    </td>
                    <td>
                        <span class="SpanId" style="display: none;">@item.ID</span> <span class="SpanName"
                            style="display: none;">@item.Code</span>
                        @item.Code
                    </td>
                    <td>
                        @item.Name
                    </td>
                     <td>
                        <img src="@Url.Content("~/Media/Product/" + item.Image)" width="70px" height="70px" alt="@item.Name" />
                    </td>
                     <td>
                        @item.CategoryNameExt
                    </td>
                    <td>
                        @Helper.StringHelper.FormatCurrencyUS(item.OldPrice)
                    </td>
                     <td>
                        @Helper.StringHelper.FormatCurrencyUS(item.Price)
                    </td>
                  <td>
                     @item.StartDate.ToShortDateString()
                  </td>
                    <td>
                     @item.EndDate.ToShortDateString()
                  </td>
                                   
                    <td>
                        @Html.CheckBoxFor(x => item.Active, new { @disabled = "disabled" })
                    </td>
                    <td>
                        @if (Helper.SessionManagement.Value("pvalue").Contains("U") || Helper.SessionManagement.Value("pvalue").Contains("C"))
                        {
                            <a title="Sửa" href="@Url.Action("AddOrUpdate", "ProductManagement", new { id = item.ID })" class="icon-pencil">
                            </a> @:&nbsp; &nbsp;
                        }
                        @if (Helper.SessionManagement.Value("pvalue").Contains("D"))
                        {
                            <a title="Xóa" href="@Url.Action("Delete", "ProductManagement", new { id = item.ID })" class="icon-trash" onclick="return confirm('Do you want delete this merchant ?');">
                            </a>
                        }
                    </td>
                </tr>
            }
        </tbody>
    </table>
}
else
{
    <h2 class="error-text">
        Not any special here.
    </h2>
}